package com.swan.knife4j.controller;

import com.swan.knife4j.domain.DemoRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * @author zongf
 * @date 2024-10-12
 **/
@RestController
@RequestMapping("/demo")
@Tag(name = "3.Demo接口", description = "测试用户接口")
public class DemoController {


    @Operation(summary = "10.getPath")
    @GetMapping("/getPath/{id}")
    public String getPath(@PathVariable("id") Integer id) {
        return this.getClass().getSimpleName() +  "-hello:" + id + ", " + LocalDateTime.now();
    }

    @Operation(summary = "11.getForm")
    @GetMapping("/getForm")
    public String getForm(@RequestParam("name") String name) {
        return this.getClass().getSimpleName() +  "-hello:" + name + ", " + LocalDateTime.now();
    }

    @Operation(summary = "12.getBean")
    @GetMapping("/getBean")
    public String getForm(DemoRequest name) {
        return this.getClass().getSimpleName() +  "-hello:" + name + ", " + LocalDateTime.now();
    }

    @Operation(summary = "21.postJson")
    @PostMapping("/postJson")
    public String postJson(DemoRequest name) {
        return this.getClass().getSimpleName() +  "-hello:" + name + ", " + LocalDateTime.now();
    }

    @Operation(summary = "22.postForm")
    @PostMapping("/postForm")
    public String postForm(@RequestBody DemoRequest name) {
        return this.getClass().getSimpleName() +  "-hello:" + name + ", " + LocalDateTime.now();
    }


}
